<?php


namespace App\Traits\Controllers;

use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;

Trait UpdateTraits
{

    /**
     * @param $id
     * @param Request $request
     * @return \Dingo\Api\Http\Response
     * @throws ValidationException
     */
    public function update($id, Request $request)
    {
        //验证用户凭证信息
        $this->validateData($request);

        $data = $this->getQuery()->findOrFail($id);

        if ($this->policy) {
            $this->authorize('update', $data);
        }

        $data->fill($request->all());
        $data->save();

        return $this->response->noContent();
    }


}
